home *** CD-ROM | disk | FTP | other *** search
- Path: news.luc.edu!user
- From: VArase@varase.it.luc.edu (Verne Arase)
- Newsgroups: comp.lang.pl1,comp.lang.c
- Subject: Re: PL/I and C
- Date: Sun, 25 Feb 1996 22:09:35 -0600
- Organization: LUMC
- Message-ID: <AD568E9F96689203B@mcdiala11.it.luc.edu>
- References: <4gh5ru$eng@goanna.cs.rmit.EDU.AU> <312CCEB2.4AB7@corp.dialog.com> <AD536AAB9668B76CD@mcdialb09.it.luc.edu> <TANMOY.96Feb23175827@qcd.lanl.gov>
- NNTP-Posting-Host: 147.126.240.111
-
- In article <TANMOY.96Feb23175827@qcd.lanl.gov>,
- tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) wrote:
-
- >VA: Actually, this is incorrect.
- >VA:
- >VA: In fact, if I recall correctly a pointer to x is implicitly an array.
- >
- >Could either of you provide examples of what you mean? I am lost ...
-
- In C, a pointer to foo is practically the same as an array of foo. The only
- difference (I believe) is that the array reserves storage, and can't have
- its base address modified.
-
- If you have
-
- foo *x; /* declare a pointer to foo */
- foo y[10]; /* declare an array of foo */
-
- x=y; /* set x to the address of y */
-
- then x[n] and y[n] should have the same address and value. A pointer to foo
- can be dereferenced as *x, and this would have a value which is a foo. A
- reference such as x[n] is actually equivalent to *(x+n) in C (in C when you
- add an integer 'n' to a pointer, it returns the address of the 'n'th
- element of that pointed-to type).
-
- ---
- The above are my own opinions, and not those of my employer.
-